package com.wei.duowan.bbs.utils;

import com.trello.rxlifecycle2.LifecycleTransformer;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 作者：赵若位
 * 时间：2019/8/1 11:27
 * 联系方式：1070138445
 * 功能：RxJava相关工具类
 */
public class RxUtils
{

    /*Observale标准的线程切换*/
    public static <T>ObservableTransformer<T,T> getSchedulers()
    {
        return new ObservableTransformer<T, T>()
        {
            @Override
            public ObservableSource<T> apply(Observable<T> observable)
            {
                return observable.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .unsubscribeOn(Schedulers.io());
            }
        };
    }


}
